# -*- Python -*-

import os

def get_required_attr(config, attr_name):
  attr_value = getattr(config, attr_name, None)
  if not attr_value:
    lit_config.fatal(
      "No attribute %r in test configuration! You may need to run "
      "tests from your build directory or add this attribute "
      "to lit.site.cfg " % attr_name)
  return attr_value

ubsan_lit_tests_dir = get_required_attr(config, "ubsan_lit_tests_dir")
ubsan_lit_cfg = os.path.join(ubsan_lit_tests_dir, "lit.common.cfg")
lit_config.load_config(config, ubsan_lit_cfg)

config.name = 'UndefinedBehaviorSanitizer-Standalone'

# Define %clang and %clangxx substitutions to use in test RUN lines.
config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
config.substitutions.append( ("%clangxx ", (" " + config.clang +
                                            " --driver-mode=g++ ")) )
